const pool = require('../config/mysql')

// 通用 query
function query(sql, ...rest) {
  return new Promise((resolve, reject) => {
    pool.query(sql, rest, function (err, results, fields) {
      if (err) {
        reject(err)
      } else {
        resolve(results)
      }
    })
  })
}

module.exports = query
